/*
 * Copyright 2006-2007 BearingPoint GDC
 *  
 *           file :     LongRunningTaskUtils.java
 *         project:     payroll
 *
 *     Create Date:     2006-12-7
 *          Author:     kevin.wang
 *
 *  [The change log]
 */

package com.mycompany.app.hr.common.longrunningtask;

import java.util.HashMap;

/**
 * Example:
 * <p>
 * LongRunningTaskHolder.REGISTRY.startTask()
 * <p>
 * LongRunningTaskHolder.REGISTRY.retrieveTask()
 * <p>
 * LongRunningTaskHolder.REGISTRY.removeTask()
 * 
 * @author kevin.wang 2006-12-7
 */

public class LongRunningTaskProgressionMeter {
    public static LongRunningTaskProgressionMeter ProgressionMeter = new LongRunningTaskProgressionMeter();

    private static HashMap<String, ILongRunningTask> map = new HashMap<String, ILongRunningTask>();

    // private static String LONG_RUNNING_TASK = "LONG_RUNNING_TASK";

    private LongRunningTaskProgressionMeter() {

    }

    // ------------------------------------------------------------------------
    //
    //
    //
    // ------------------------------------------------------------------------

    public static synchronized void addTask(String taskName,
            ILongRunningTask task) {

        map.put(taskName, task);
    }

    public static synchronized ILongRunningTask retrieveTask(String taskName) {

        return map.get(taskName);
    }

    public static synchronized void removeTask(String taskName) {

        map.remove(taskName);
    }
}
